﻿
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;
using Product_1.ServiceReference1;
using ReactiveUI;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Product_1.ViewModels
{
    public class Product_1_ViewModel : ReactiveUI.ReactiveObject
    {     
        ServiceReference1.Container context = new ServiceReference1.Container(new Uri("http://localhost:1179/odata"));

        IQueryable<Bacchu> region1;
        public IQueryable<Bacchu> Region1
        {
            get
            {
                return region1;
            }
            set  //DependencyProperty coding
            {
                this.RaiseAndSetIfChanged(ref region1, value);
            }
        }

        public ReactiveCommand<object> Initialize { get; private set; }

        public Product_1_ViewModel()
        {
            Initialize = ReactiveCommand.Create(
            this.WhenAny(vm => vm.Region1, str => true)
            );
            Initialize.Subscribe(_ =>
            {
                Region1 = (IQueryable<Bacchu>)context.Bacchus.Select(kkk=>kkk);
            });         
        }

        public event EventHandler Result = delegate { };
    }
}